package com.sancorseguros.nova.selenium.pageobject;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

import com.sancorseguros.nova.selenium.config.StaticSelenium;

public class SSHomePage extends AbstractPage {

	private static final long serialVersionUID = 7563580530523404088L;

	private WebDriver driver;
		
    public SSHomePage(WebDriver driver) throws InterruptedException {  
        super();  
        this.setDriver(driver);
        this.setTitle(StaticSelenium.TITLE_SS_HOME);
        this.goToHome(this.getDriver());
    } 
	
	public void goToHome(WebDriver driver) throws InterruptedException { 
		driver.get(StaticSelenium.LOCAL_HOST+":"+StaticSelenium.PORT+StaticSelenium.NOVA_HOME);		
		this.waitForTitle(StaticSelenium.TITLE_SS_HOME, this.getTitle());
	}	
	
	public LoginNovaPage goToLogin(WebDriver driver) throws InterruptedException {
		driver.findElement(By.xpath("//a[@class='login']")).click();
		Thread.sleep(StaticSelenium.PAUSE_TIME);
		return new LoginNovaPage(this.getDriver());
	}

	@Override
	public void validatePage() {
		assertTrue(StaticSelenium.INVALID_PAGE, this.verifyPage(this.getDriver(), StaticSelenium.TITLE_SS_HOME));		
	}

	public WebDriver getDriver() {
		return driver;
	}

	public void setDriver(WebDriver driver) {
		this.driver = driver;
	}


}
